package qc.module.cms.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import qc.common.core.exception.QCPromptException;
import qc.module.cms.dto.ledview.LedViewDto;
import qc.module.cms.service.LedViewService;

import java.util.List;

/**
 * LedViewController
 *
 * @author QuCheng Tech
 * @since 2023/12/26
 */
@RestController
@RequestMapping("/ledview")
public class LedViewController {
    private LedViewService ledViewService;

    @Autowired
    public void setLedViewService(LedViewService ledViewService) {
        this.ledViewService = ledViewService;
    }

    /**
     * 查询所有画面信息
     *
     * @return java.util.List<qc.module.cms.dto.ledview.LedViewDto>
     * @author QuCheng Tech
     * @since 2023/12/26
     */
    @RequestMapping(value = "/query", method = {RequestMethod.GET})
    public List<LedViewDto> query() throws QCPromptException {
        return ledViewService.getAll();
    }

    /**
     * 获取指定画面信息
     *
     * @param id 画面ID
     * @return qc.module.cms.dto.ledview.LedViewDto
     * @author QuCheng Tech
     * @since 2023/12/26
     */
    @RequestMapping(value = "/get", method = {RequestMethod.GET})
    public LedViewDto getByParam(@RequestParam int id) throws QCPromptException {
        return ledViewService.get(id);
    }

    /**
     * 获取指定画面信息
     *
     * @param id 画面ID
     * @return qc.module.cms.dto.ledview.LedViewDto
     * @author QuCheng Tech
     * @since 2023/12/26
     */
    @RequestMapping(value = "/get/{id}", method = {RequestMethod.GET})
    public LedViewDto getByPath(@PathVariable(required = true) int id) throws QCPromptException {
        return ledViewService.get(id);
    }

    /**
     * 新增
     *
     * @param dto 画面信息
     * @return java.lang.String
     * @author QuCheng Tech
     * @since 2023/12/26
     */
    @RequestMapping(value = "/add", method = {RequestMethod.POST})
    public String add(@RequestBody LedViewDto dto) {
        return ledViewService.add(dto);
    }

    /**
     * 修改
     *
     * @param dto 画面信息
     * @return java.lang.String
     * @author QuCheng Tech
     * @since 2023/12/26
     */
    @RequestMapping(value = "/update", method = {RequestMethod.PUT, RequestMethod.POST})
    public String update(@RequestBody LedViewDto dto) {
        return ledViewService.update(dto);
    }

    /**
     * 删除
     *
     * @param id 画面ID
     * @return java.lang.String
     * @author QuCheng Tech
     * @since 2023/12/26
     */
    @RequestMapping(value = "/delete", method = {RequestMethod.DELETE})
    public String deleteByParam(@RequestParam int id) {
        return ledViewService.delete(id);
    }

    /**
     * 删除
     *
     * @param id 画面ID
     * @return java.lang.String
     * @author QuCheng Tech
     * @since 2023/12/26
     */
    @RequestMapping(value = "/delete/{id}", method = {RequestMethod.DELETE})
    public String deleteByPath(@PathVariable(required = true) int id) {
        return ledViewService.delete(id);
    }
}
